package com.dxj1992.controller.admin;


import com.dxj1992.entity.AdminPermissions;
import com.dxj1992.entity.AdminUsers;
import com.dxj1992.service.IAdminPermissionsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/admin")
@Slf4j
public class IndexController extends BaseController {

    @Autowired
    private IAdminPermissionsService iAdminPermissionsService;

    @GetMapping("/index")
    public String login(HttpServletRequest request, ModelMap mmap) {
        AdminUsers user = getSysUser(request);
        List<AdminPermissions> adminPermissions = iAdminPermissionsService.selectMenu(user);
        mmap.put("menus", adminPermissions);
        mmap.put("user", user);
        return "admin/index";
    }

    @GetMapping("/main")
    public String main() {
        return "admin/main";
    }
}
